<?php
// 获取所有用户列表
// header("content-type:text/html;charset=utf-8");
include_once("conn.php");

$sql = "SELECT * FROM tb_user_info ORDER BY id DESC";
$result = mysqli_query($conn, $sql);
if ($result) {
    $num = mysqli_num_rows($result);
    echo "<div class='layui-card-header'>当前平台总用户量：<span class='userCount'>" . $num . "</span></div>";
    echo "
            <div class='layui-card-body'>
                <table class='table table-hover table-striped'>
                    <thead>
                        <tr>
                            <th scope='col'>用户ID</th>
                            <th scope='col'>用户昵称</th>
                            <th scope='col'>联系方式</th>
                            <th scope='col'>注册时间</th>
                            <th scope='col'>账号状态</th>
                            <th scope='col'>状态更改时间</th>
                        </tr>
                    </thead>
                    <tbody>";
    if ($num > 0) {
        while ($row = mysqli_fetch_assoc($result)) {
            if ($row['ustatus'] == "正常") {
                $row['ustatus'] = "<td style='color:limegreen;'>正常</td>";
            } else {
                $row['ustatus'] = "<td style='color:tomato;'>封禁</td>";
            }
            echo "<tr>
                    <td>" . $row['uid'] . "</td>
                    <td>" . $row['uname'] . "</td>
                    <td>" . $row['uphone'] . "</td>
                    <td>" . $row['uregdate'] . "</td>".$row['ustatus']."
                    <td>" . $row['uchangedate'] . "</td>
                </tr>";
        }
    }else{
        echo "<tr><td colspan='5'>暂无用户数据</td></tr>";
    }
    echo "</tbody></table></div>";
} else {
    echo "查询失败";
}
